package frame;

import pojo.UserDO;
import util.GuiImg;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.*;

public class Atm extends JFrame implements ActionListener {
    CardLayout cardLayout = new CardLayout();
    private Image atmImg = GuiImg.getImage("/imgs/background.jpg");

    private Check check = new Check(this);
    private Login login = new Login(this);
    private Menu menu = new Menu(this);
    private Deposit deposit = new Deposit(this);
    private Get get = new Get(this);
    private Alter alter = new Alter(this);
    private Transfer transfer = new Transfer(this);
    private static Atm atm = new Atm();
    private int index;
    private UserDO loginuser;


    public Atm() {
        this.setContentPane(new JPanel() {
            @Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                g.drawImage(atmImg, 0, 0, 800, 600, this);
            }
        });
        this.setLayout(cardLayout);
        //登录
        this.add("登录", login);
        //菜单
        this.add("菜单", menu);
        //存款
        this.add("存款", deposit);
        //取款
        this.add("取款", get);
        //查询
        this.add("查询", check);
        //改密
        this.add("改密", alter);
        //转账
        this.add("转账", transfer);

        //界面初始化
        this.setSize(800, 600);
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setLocationRelativeTo(null);
        this.setVisible(true);
    }

    @Override
    public void actionPerformed(ActionEvent e) {

    }

    public static void main(String[] args) {
        new Atm();
    }

    public void switchPanel(String name) {
        cardLayout.show(this.getContentPane(), name);
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public Check getCheck() {
        return check;
    }

    public void setCheck(Check check) {
        this.check = check;
    }

    public Deposit getDeposit() {
        return deposit;
    }

    public void setDeposit(Deposit deposit) {
        this.deposit = deposit;
    }

    public Menu getMenu() {
        return menu;
    }

    public void setMenu(Menu menu) {
        this.menu = menu;
    }

    public UserDO getLoginuser() {
        return loginuser;
    }

    public void setLoginuser(UserDO loginuser) {
        this.loginuser = loginuser;
    }

}
